﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Pigmalion.BusinessEntities;
using Pigmalion.Presenter.ProductoPresenter;



namespace Pigmalion.UIWF.Almacen
{
    public partial class ProductoMttoView : Form,IProductoMttoView
    {

        ProductoMttoPresenter presenter;

        public ProductoMttoView()
        {
            InitializeComponent();
            presenter = new ProductoMttoPresenter(this);
            presenter.CargarCategorias();
        }


        public Producto CurrentProduct  {get;set;}
 
        public void NewProduct()
        {
            productoBindingSource.AddNew();
            Text = "Nuevo Producto";

        }

        public void EditProduct()
        {
            productoBindingSource.DataSource = CurrentProduct;
            Text = "Editar: " + CurrentProduct.Descripcion;
        }        

        private void btnGuardar_Click(object sender, EventArgs e)
        {
            Producto producto = productoBindingSource.Current as Producto;

            presenter.RegistarProducto(producto);
        }

        public List<Categoria> Categorias
        {
            set { categoriaBindingSource.DataSource = value; }
        }

        private void ProductoMttoView_Load(object sender, EventArgs e)
        {
           
        }

        private void btnSalir_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
